package day_3;/*
 *@ 代阳敲的专属代码
 **/
import java.util.Scanner;
public class Test {
    public static void main(String[] args) {
        new worker(18,"代阳",10000);
    }
}
class worker {
    private int age;
    public String name;
    private int salary;
    worker(int age, String name, int salary) {
        setAge(age);
        setName(name);
        setSalary(salary);
    }


    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        if(age < 1 && age > 120) {
            throw new IllegalArgumentException("年龄在1-120之间");
        }
        this.age = age;
    }

    public String getName() {

        return name;
    }

    public void setName(String name) {
        if(name.length() < 2 || name.length() > 6) {
            throw new IllegalArgumentException("名字长度在2-6之间");
        }
        this.name = name;
    }

    public int getSalary() {
        return salary;
    }

    public void setSalary(int salary) {
        System.out.println("请输入密码");
        Scanner sc = new Scanner(System.in);
        String pwd = sc.next();
        if(pwd.equals("123456")){
            System.out.println("密码正确");

        } else {
            System.out.println("密码错误");
        }
        this.salary = salary;
    }
}